Kinetis SDK Demo Applications User Guide  1.0.0-beta
Freescale Semiconductor, Inc.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
fsl_mma8451.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without modification,
6  * are permitted provided that the following conditions are met:
7  *
8  * o Redistributions of source code must retain the above copyright notice, this list
9  * of conditions and the following disclaimer.
10  *
11  * o Redistributions in binary form must reproduce the above copyright notice, this
12  * list of conditions and the following disclaimer in the documentation and/or
13  * other materials provided with the distribution.
14  *
15  * o Neither the name of Freescale Semiconductor, Inc. nor the names of its
16  * contributors may be used to endorse or promote products derived from this
17  * software without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
23  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
26  * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29  */
30 
31 #if !defined(__FSL_MMA8451_H__)
32 #define __FSL_MMA8451_H__
33 
34 #include "i2c_master/fsl_i2c_master_driver.h"
35 
40 {
60 };
61 
65 typedef struct _mma8451_device {
66  i2c_device_t address;
68 
72 typedef struct _acceleration {
73  int32_t x;
74  int32_t y;
75  int32_t z;
77 
78 /*******************************************************************************
79  * API
80  ******************************************************************************/
81 
82 #if defined(__cplusplus)
83 extern "C" {
84 #endif
85 
99 int32_t mma8451_init(mma8451_device_t *device, uint8_t i2c_addr, uint32_t baud_kbps);
100 
111 int32_t mma8451_get_acceleration(const mma8451_device_t * device, acceleration_t * accel);
112 
121 uint8_t mma8451_read_register(const mma8451_device_t * device, uint8_t reg_addr);
122 
133 int32_t mma8451_write_register(const mma8451_device_t * device, uint8_t reg_addr, uint8_t reg_val);
134 
135 
136 #if defined(__cplusplus)
137 }
138 #endif
139 
140 #endif
Definition: fsl_mma8451.h:50
Definition: fsl_mma8451.h:41
int32_t mma8451_get_acceleration(const mma8451_device_t *device, acceleration_t *accel)
Read the current acceleration values.
Definition: fsl_mma8451.c:116
i2c_device_t address
Definition: fsl_mma8451.h:66
Definition: fsl_mma8451.h:52
uint8_t mma8451_read_register(const mma8451_device_t *device, uint8_t reg_addr)
Read a single register of the MMA8451.
Definition: fsl_mma8451.c:49
Definition: fsl_mma8451.h:56
Definition: fsl_mma8451.h:46
Definition: fsl_mma8451.h:58
Definition: fsl_mma8451.h:53
int32_t x
Definition: fsl_mma8451.h:73
MMA8451 driver instance.
Definition: fsl_mma8451.h:65
Definition: fsl_mma8451.h:55
3D acceleration values.
Definition: fsl_mma8451.h:72
int32_t mma8451_init(mma8451_device_t *device, uint8_t i2c_addr, uint32_t baud_kbps)
Initialize the MMA8451 driver instance.
Definition: fsl_mma8451.c:66
Definition: fsl_mma8451.h:59
Definition: fsl_mma8451.h:43
Definition: fsl_mma8451.h:47
int32_t z
Definition: fsl_mma8451.h:75
Definition: fsl_mma8451.h:49
Definition: fsl_mma8451.h:42
Definition: fsl_mma8451.h:54
_mma8451_constants
Register definitions for the MMA8451.
Definition: fsl_mma8451.h:39
int32_t y
Definition: fsl_mma8451.h:74
Definition: fsl_mma8451.h:44
Definition: fsl_mma8451.h:45
Definition: fsl_mma8451.h:48
Definition: fsl_mma8451.h:57
int32_t mma8451_write_register(const mma8451_device_t *device, uint8_t reg_addr, uint8_t reg_val)
Write a single register of the MMA8451.
Definition: fsl_mma8451.c:58
Definition: fsl_mma8451.h:51